<template>
  <div class="home">
    <h1>欢迎来到校园活动管理系统</h1>
    <nav>
      <router-link to="/public-activities">公开活动列表</router-link>
      <router-link 
        v-if="isAdmin" 
        to="/activity-management"
      >
        活动管理
      </router-link>
      <button @click="logout" class="logout-btn">退出登录</button>
    </nav>
  </div>
</template>

<script>
export default {
  name: 'Home',
  computed: {
    isAdmin() {
      return localStorage.getItem('userRole') === 'admin'
    }
  },
  methods: {
    logout() {
      localStorage.removeItem('userRole')
      this.$router.push('/login')
    }
  }
}
</script>

<style scoped>

nav {
  display: flex;
}
nav a {
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid #0087ff;
  border-radius: 4px;
}
nav a:hover {
  background-color: #0087ff;
}
.logout-btn {
  margin-left: auto;
  background-color: #f56c6c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.logout-btn:hover {
  background-color: #e74c3c;
}
</style>
